package com.xiaotao.controller;

import com.xiaotao.entity.Scoring;
import com.xiaotao.service.ScoringService;
import com.xiaotao.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/scorings")
public class ScoringController {

    @Resource
    private ScoringService scoringService;

    // 新增评分（对应小程序首次评分）
    @PostMapping("/add")
    public ResponseUtil addScoring(@RequestBody Scoring scoring) {
        return scoringService.add(scoring);
    }

    @GetMapping("/query")
    public ResponseUtil queryByUserId(@RequestParam("userId") Integer userId) {
        System.out.println("收到查询评分请求，用户ID：" + userId);
        return scoringService.queryByUserId(userId);
    }

    @PostMapping("/update")
    public ResponseUtil updateScoring(@RequestBody Scoring scoring) {
        return scoringService.update(scoring);
    }
}